import routerList from "@/router/router.js"
let webService = (()=>{
    return process.env.VUE_APP_IS_WEB_SEVICE =='server' ? true : false
})()
let routes = [
    {
        path:"/",
        redirect:"/index",
    },
    {
        path: "*",
        // component: errPage
    }
];

function generateRoute (){
    // 是web系统 后台管理系统的时候
    if(webService){
        routerList.forEach(item => {
            item.path=item.path.slice(1)
        });
        routes.push(
            {
                path:"/login",
                component:()=> import('../views/loginPage/loginPage.vue')
            },
            {
                path: '/index',
                name: 'index',
                redirect:`/index/${routerList[0].path}`,
                component: () => import( '../views/index.vue'),
                children:[
                    ...routerList
                ]
            }
        )
    }else{
        // 如果是其他系统 
        routes.push(...routerList)
    }
    return routes
}
export default generateRoute();